package com.datastructure.test.symmetricalbinarytree;

import java.util.ArrayList;
import java.util.Objects;

public class SymmetricalBinaryTree {
    ArrayList<ArrayList<Integer>> res = new ArrayList<>();
    public static void main(String[] args) {

    }

    public boolean isSymmetrical(TreeNode root) {
        return check(root, root);
    }
    boolean check(TreeNode a, TreeNode b) {
        if (a == null && b == null) return true;
        if (a == null || b == null) return false;
        if (a.val != b.val) return false;
        return check(a.left, b.right) && check(a.right, b.left);
    }
}
class TreeNode {
    int val = 0;

    public TreeNode(int val) {
        this.val = val;
    }

    TreeNode left = null;
    TreeNode right = null;
}